<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let num = ''
      let abc = 'a'
      let falg = 1
      let obj = [{ name: '陈杨', age: 18, sex: '男' }]
      while (true) {
        let choose = +prompt(`1新增   2删除 3退出`)
        if (choose == 1) {
          let num1 = prompt('输入用户名')
          let num2 = +prompt('输入年纪')
          let num3 = prompt('输入性别')
          obj.push({ name: num1, age: num2, sex: num3 })
          for (let i = 0; i < obj.length; i++) {
            num =num +'用户名：' +obj[i].name +'年纪：' +obj[i].age +'性别：' +obj[i].sex +'\n'
          }
          alert(num)
          num = ''
        }
        if (choose == 2) {
          let sun = prompt('删除用户名')
          for (let i = 0; i < obj.length; i++) {
            if (sun == obj[i].name) {
              obj.splice(i, 1)
              abc = 'b'
            }
            num = num +'用户名：' +
              obj[i].name +
              '年纪：' +
              obj[i].age +
              '性别：' +
              obj[i].sex +
              '\n'
          }
          if (abc == 'a') {
            alert('没有该用户名')
          }
          alert(num)
          num = ''
        }
        if (choose == 3) {
          aletr('正在退出')
          falg = 0
        }
        if (falg == 0) {
          break
        }
      }
    </script>
  </body>
</html>
